<?php
$removeNeed = FALSE;

if($type == 'page') $links -> menu($catInfo->subMenu,1,$catInfo);
	if(isset($page))
		if (count($page) > 0)
		{	include_once("content/PageTypeDisplay.php");
			foreach ($page as $pg)
			{?>
			<dl id='page-<?=$pg->id?>'>
				<dt><h1><?=$pg->title?></h1></dt>
				<dd>
					<?
						PageTypeDisplay($pg);
					if(
						$userPerm->checkPerm( $this->session->userdata('user_id'),'re', '', $pg->id)
					){
						echo '<div class="menuControl"><a href="'.$links ->makeLink('adm/admpage/edit/'.$pg->id).'" title='.$pg->title.' class="ui-state-default ui-corner-all">
											<span class="ui-icon ui-icon-pencil">&nbsp;</span>&nbsp;Редактировать</a></div>';
					}
					if(
						$userPerm->checkPerm( $this->session->userdata('user_id'),'rw', '', $pg->id)
					){ $removeNeed = TRUE;?>
						<div class='menuControl'>
								<a href='#' class="ui-state-default ui-corner-all" title='<?=$pg->title?>' id='<?=$pg->id?>'>
												<span class="ui-icon ui-icon-minus">&nbsp;</span>&nbsp;Удалить страницу</a>
						</div>
					<?}?>
		     		</dd>
			</dl>
			<?}
			if($removeNeed){?>
				<script type="text/javascript" src="<?=$links->base_url?>js/jquery/forms/adminPageRemove.js"></script>
				<div id="dialogRemoveConfirm" title="Удалить страницу?">
					<p>
						<span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>
						Вы уверенны, что хотите удалить страницу "<span id='removePageId'></span>"?</p>
					<form id='pageRemoveForm' method='POST' action="<?=$links->makeLink( 'adm/admpage/remove' )?>" style='display:none'>
						<label for='pageToRemove'>ID удаляемой страницы</label><input name='pageId' id='pageToRemove' value='' />
					</form>
				</div>
			<?}
		} else {
			echo $lang->language['Error404'];
		}
		
		
if(
	$userPerm->checkPerm( $this->session->userdata('user_id'),'rw', $catInfo->id)
){
	echo '<div  class="menuControl"><a href="'.$links ->makeLink('adm/admpage/add/'.$catInfo->id).'" class="ui-state-default ui-corner-all">
					<span class="ui-icon ui-icon-plus">&nbsp;</span>&nbsp;Добавить страницу</a></div>';
}
